﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NWBA_Public
{
    public class LoginBusinessObject
    {
        public static Customer LoginUser(string username, string password)
        {
            //NWBAEntities database = new NWBAEntities();
            WDTConnectionString database = new WDTConnectionString();
            //hash the password using the .HashPassword() method in the serverstring.cs
            password = LoginUpdate.HashPassword(username, password);
            Login login = database.Logins.FirstOrDefault(
                          l => l.UserID == username && l.Password == password);
            if (login == null)
            {
                return null;
            }
            else
            {
                return login.Customer;
            }
        }
    }
}